package com.acme.bankapp.domain.bank;

/**
 * Class implements Checking type of Account with overdraft possibility
 * Constructor expects nonNegative overdraft
 * @author Vasilyev Anton
 *
 */
public class CheckingAccount extends AbstractAccount implements Account {
	private double overdraft;

	public CheckingAccount(double balance, double overdraft) {
		super(balance);
		assert(overdraft >= 0);
		this.overdraft = overdraft;
	}
	public CheckingAccount(double balance) {
		this(balance, 0.0);
	}

	public double maxAmountToWithdraw() {
		return this.balance + this.overdraft;
	}

	@Override
	public void withdraw(double amount) {
		if (this.balance + this.overdraft >= amount) {
			this.balance -= amount;
		}
		assert(this.balance + this.overdraft>= 0);
			
	}

}
